<!DOCTYPE html>
<html class="x-admin-sm">
{include file='public/header'}
<body>
    <div class="x-body">
        <form class="layui-form" lay-filter="formAjax">
            <div class="layui-form-item">
                <label class="layui-form-label">公司主体：</label>
                <div class="layui-input-block">
                    <input type="radio" name="company_entity_id" lay-filter="company_entity_id" value="" title="全部" checked>
                    <input type="radio" name="company_entity_id" lay-filter="company_entity_id" value="1" title="比翼鸟">
                </div>
            </div>
            <div class="layui-form-item" style='display: flex;'>
                <label class="layui-form-label">
                    <span class="x-red">*</span>选择小程序
                </label>
                <div id="GetAuthorizers" style="width: 100%;flex: 1;"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">操作类型：</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" lay-filter="type" value="postRelease" title="发布">
                    <input type="radio" name="type" lay-filter="type" value="postRevertCodeRelease" title="版本回退">
                    <input type="radio" name="type" lay-filter="type" value="postSpeedupCodeAudit" title="加急审核">
                    <input type="radio" name="type" lay-filter="type" value="postUndoAudit" title="撤回审核">
                    <input type="radio" name="type" lay-filter="type" value="postBindTester" title="添加体验者">
                    <input type="radio" name="type" lay-filter="type" value="postUnBindTester" title="移除体验者">
                </div>
            </div>
            <div class="layui-form-item" id="tester" style="display: none;">
                <label class="layui-form-label">
                    微信号
                </label>
                <div class="layui-input-block">
                    <input type="text" name="wechat_id" placeholder="请输入微信号" autocomplete="off" class="layui-input" value="" />
                </div>
            </div>
            <button id="submitData" class="layui-btn" lay-submit lay-filter="submitData" style="display: none;" />
        </form>
    </div>
    <script>
        layui.use(["form", "layer"], function () {
            var form = layui.form,
                layer = layui.layer;
            form.on('radio(type)', function(data){
                if(data.value == "postBindTester" || data.value == "postUnBindTester"){
                    $('#tester').show()
                }else{
                    $('#tester').hide()
                }
            })
            form.on('radio(company_entity_id)', function(data){
                xmSelectGetAuthorizersOption.url = '/admin/OpenWeixin/getAuthorizersSelect?company_entity_id='+data.value
                xmSelectA(xmSelectGetAuthorizersOption)
            });
            form.on('submit(submitData)', function(data){
                var formData = data.field;
                batchTask({
                    app_ids:form.val("formAjax").app_id.split(','),
                    task_method:formData.type,
                    task_data:formData.type == 'postBindTester' || formData.type == 'postUnBindTester' ? {wechat_id:formData.wechat_id} : []
                })
                return false
            });
        });

        let xmSelectGetAuthorizersOption = {
            initValue:'',//初始值
            el:'#GetAuthorizers',
            url:'/admin/OpenWeixin/getAuthorizersSelect',
            direction:'down',//下拉方向
            pageSize:8,
            isData:true,
            prop:{
                name:'app_name',
                value:"app_id"
            },
            name:'app_id',
        }
        xmSelectA(xmSelectGetAuthorizersOption)
    </script>
</body>

</html>